import time

from selenium import webdriver



driver = webdriver.Chrome()
driver.get('http://beike.zxxk.com/index.html#/')
driver.implicitly_wait(10)
time.sleep(2)
driver.switch_to.frame('frame')

# 登录
driver.find_element_by_id('username').send_keys('18820071443')
driver.find_element_by_name('password').send_keys('po520131400')
driver.find_element_by_id('CommonLogin').submit()
time.sleep(5)

driver.find_element_by_css_selector('.textbook-change.iconfont.iconqiehuan').click()
time.sleep(5)
driver.find_element_by_css_selector('.textbook-change.iconfont.iconqiehuan').click()
time.sleep(5)

driver.find_element_by_css_selector('.bk-base-btn.bk-primary-btn.plain.find-more.padding.fr').click()
time.sleep(5)

driver.find_element_by_css_selector('.bk-logo').click()
time.sleep(5)


driver.find_element_by_xpath('//div[@class="div-list-item has-child"]/div/div/div/button/span[contains(text(),"授课")]').click()
time.sleep(5)

driver.find_element_by_xpath("['//div[@class='div-list-item has-child' and @title='长按可拖动']/div/div/div/span/span]").click()
time.sleep(5)

driver.find_element_by_xpath('//div[@id="el-popover-7005"]/ul/li[@title="移动到"]').click()
time.sleep(5)

driver.find_element_by_xpath('//div[@class="el-dialog__body"]following-sibling::div/div/button[@class="bk-base-btn bk-primary-btn padding"]').click()
time.sleep(5)

driver.find_element_by_xpath('['//div[@class="div-list-item has-child" and @title="长按可拖动"]/div/div/div/span/span']').click()
time.sleep(5)

driver.find_element_by_xpath('//div[@id="el-popover-7005"]/ul/li[@title="重命名"]').click()
time.sleep(5)

driver.find_element_by_xpath('['//div[@class="div-list-item has-child" and @title="长按可拖动"]/div/div/div/span/span']').click()
time.sleep(5)

driver.find_element_by_xpath('['//div[@id="el-popover-7005"]/ul/li[@title="删除"]').click()
time.sleep(5)

driver.find_element_by_xpath('['//div[@class="el-dialog__body"]/following-sibling::div/div/button[@class="bk-base-btn bk-primary-btn padding"]').click()
time.sleep(5)

driver.find_element_by_css_selector('.iconfont.iconxinjian').click()
time.sleep(5)

driver.find_element_by_xpath('//button[@style="position: relative; z-index: 1;"]').click()
                


'''
 5）轴定位
   1.parent:: 上层父节点，爸爸 只找一个 例子 //input[@id='kw' and @name='wd']/parent::span
   2.ancestor：：上面的所有节点 祖先(爸爸、爷爷 ...)
   3.preceding-sibling：：同层上阶段，就是哥哥姐姐
   4.following-sibling：： 同层下节点，就是弟弟妹妹
   5.child：：下层所有子节点 儿子们

#切换教材
.textbook-change.iconfont.iconqiehuan
[class="textbook-change iconfont iconqiehuan"]

//div//span[contains(@class,'iconqiehuan')]
//span[@title="切换教材" and @class="textbook-change iconfont iconqiehuan"]
//span[@class="textbook-change iconfont iconqiehuan"]
//div[@class="bk-textbook"]/child::span[@class="textbook-change iconfont iconqiehuan"]
//div[@class="bk-textbook"]//span[text()='切换教材']

#找资源
.bk-base-btn.bk-primary-btn.plain.find-more.padding.fr
[class="bk-base-btn bk-primary-btn plain find-more padding fr"]

//div//button[contains(@class,'ind-more padding f')]
//button[contains(text(),'找资源')]


//button[@class="bk-base-btn bk-primary-btn plain find-more padding fr"]
//button[@class="bk-base-btn bk-primary-btn fl"]/following-sibling::button[@class="bk-base-btn bk-primary-btn plain find-more padding fr"]
//div[@class="bk-sources-tool"]/child::button[@class="bk-base-btn bk-primary-btn plain find-more padding fr"]

#备课
.bk-base-btn.bk-primary-btn.plain.padding7
[class="bk-base-btn bk-primary-btn plain padding7"]

//div//button[contains(@class,'bk-primary-btn plain padding7')]
//div[@class="list-item-right"]//button[contains(text(),'备课')]

//button[@class="bk-base-btn bk-primary-btn plain padding7"]
//div[@class="list-item-right"]/child::button[@class="bk-base-btn bk-primary-btn plain padding7"]
//div[@class="bk-hot-list"]/div[@class="div-list-item has-child"]/div[@class="list-item-parent"]/div[@class="list-item-icon"]/following-sibling::div[@class="list-item-right"]

#首页返回路径
.bk-logo
[class="bk-logo"]

#授课
//div[@class="div-list-item has-child"]/div/div/div/button/span[contains(text(),'授课')]

//div[@class="div-list-item has-child"]/div/div/div/button/child::i[@class="fl iconfont iconshouke"]
//div[@class="div-list-item has-child"]/div/div/div/button/child::i[@class="fl iconfont iconshouke"]/following-sibling::span[@class="fl"]

#移动到
['//div[@class="div-list-item has-child" and @title="长按可拖动"]/div/div/div/span/span'] #先点击更多
//div[@id="el-popover-7005"]/ul/li[@title="移动到"] #再点击移动到
//div[@class="el-dialog__body"]following-sibling::div/div/button[@class="bk-base-btn bk-primary-btn padding"] #取消


#重命名
['//div[@class="div-list-item has-child" and @title="长按可拖动"]/div/div/div/span/span'] #先点击更多
//div[@id="el-popover-7005"]/ul/li[@title="重命名"] #再点击移动到

#删除
['//div[@class="div-list-item has-child" and @title="长按可拖动"]/div/div/div/span/span'] #先点击更多
//div[@id="el-popover-7005"]/ul/li[@title="删除"] #再点击移动到
//div[@class="el-dialog__body"]/following-sibling::div/div/button[@class="bk-base-btn bk-primary-btn padding"] #取消

#新建文件夹
.iconfont.iconxinjian
[class="iconfont iconxinjian"]

//button//i[contains(@class,'iconxinjian')]
//button[contains(text(),'新建文件夹')]
//i[@class="iconfont iconxinjian"]
//i[@class="iconfont iconxinjian"]/parent::button[@class="bk-base-btn bk-primary-btn fl"]
//i[@class="iconfont iconxinjian"]/ancestor::button[@class="bk-base-btn bk-primary-btn fl"]
//div[@id="bk-upload-container"]/following-sibling::button[@class="bk-base-btn bk-primary-btn fl"]
//div[@class="bk-sources-tool"]/child::button[@class="bk-base-btn bk-primary-btn fl"]
//div[@class="bk-sources-tool"]/child::button[@class="iconfont iconxinjian"]
//div[@id="bk-upload-container"]/child::button[@class="bk-base-btn bk-primary-btn fl"]
//div[@id="bk-upload-container"]/child::button[@class="bk-base-btn bk-primary-btn fl"]/i[@class="iconfont iconshangchuan"]
//button[@class="bk-base-btn bk-primary-btn fl"]/child::i[@class="iconfont iconshangchuan"]


#上传
//button[contains(@style,'relative; z-index: 1;')]
//button[contains(text(),'上传')]

//button[@style="position: relative; z-index: 1;"]
//button[@style="position: relative; z-index: 1;"]/i
//button[@style="position: relative; z-index: 1;"]/i[@class="iconfont iconshangchuan"]


//button[@class="bk-base-btn bk-primary-btn fl" and @style="position: relative; z-index: 1;"]

'''

time.sleep(10)
driver.quit()
